
<form class="form-signin">
    <h2 class="form-signin-heading">Registrate</h2>
    <input type="input" class="form-control" placeholder="Usuario" required autofocus ng-model="usuario.id">

    <img style="display:none;width:60px;height:60px;" id="smallImage" src="" />

    <button class="btn btn-lg btn-primary btn-block" type="button"  onclick="sacarFoto()">Foto</button>
    <button class="btn btn-lg btn-primary btn-block" type="button"  onclick="buscarFoto()">Buscar foto</button>

    <button class="btn btn-lg btn-primary btn-block" type="submit"  ng-click="registrar()">Registrar</button>
</form>

<script type="text/javascript" >

    var pictureSource;   // picture source
    var destinationType; // sets the format of returned value

    // Wait for device API libraries to load
    document.addEventListener("deviceready",onDeviceReady,false);

    // device APIs are available
    function onDeviceReady() {
        pictureSource=navigator.camera.PictureSourceType;
        destinationType=navigator.camera.DestinationType;
    }


    function sacarFoto() {
// Take picture using device camera and retrieve image as base64-encoded string
        navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
            destinationType: destinationType.DATA_URL });
    }


    // Called when a photo is successfully retrieved
    //
    function onPhotoDataSuccess(imageData) {
        // Uncomment to view the base64-encoded image data
        // console.log(imageData);

        var smallImage = document.getElementById('smallImage');

        // Unhide image elements
        smallImage.style.display = 'block';

        // Show the captured photo
        // The inline CSS rules are used to resize the image
        smallImage.src = "data:image/jpeg;base64," + imageData;
        {{usuario.avatar=imageData}}
    }

    // A button will call this function
    //
    function buscarFoto() {
        // Retrieve image file location from specified source
        navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
            destinationType: destinationType.FILE_URI,
            sourceType: pictureSource.SAVEDPHOTOALBUM });
    }

</script>
